#!/usr/bin/env python
import re
dir = 'output/'
f = open (dir + 'output3.txt', 'r')

output = ''
isEigenMax, isEigenMin, isNorms = False, False, False

count = 0
for line in f.readlines() :
	print (line)
	line = line.strip()
	if len(line) == 0 : continue
	if re.match('ite-.*', line) :
		output += line + '\t'
		isEigenMin = False
		isEigenMax = False
		isNorms = False
	if isEigenMax and count < 3:
		output += line.replace('.', ',') + '\t'
		count += 1
		continue
	if isEigenMin and count < 3 :
		output += line.replace('.', ',') + '\t'
		count += 1
		continue
	if isNorms :		
		output += line.replace('.', ',')
		output += '\n'
		continue
		
	
	if 	re.match('Large.*', line) :
		isEigenMax = True
		isEigenMin = False
		isNorms = False
	if re.match('Small.*', line) :
		isEigenMin = True
		isEigenMax = False
		isNorms = False
	if re.match('n1.*', line) :
		
		isNorms = True
		isEigenMin = False
		isEigenMax = False
	
	if count == 3 :
		count = 0

lines =  output.split('\n')

out = open(dir + 'output9.txt', 'w')
list.reverse(lines)
for line in lines :
	out.write(line + '\n')
	
out.flush()
out.close()